package com.sunrise.xdoc.entity.catalog;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.sunrise.xdoc.entity.AbstractCodeEntity;
import com.sunrise.xdoc.entity.config.ChiNhanh;

@Entity
@Table(name = "catalog_loai_san_pham")
@Inheritance(strategy = InheritanceType.JOINED)
public class LoaiSanPham extends AbstractCodeEntity {
	private static final long serialVersionUID = 1L;
	private ChiNhanh chiNhanh;
	private String name;

	@ManyToOne
	@JoinColumn(name = "chi_nhanh_id")
	@NotNull(message = "Loại SP chưa có chi nhánh. Vui lòng kiểm tra lại")
	public ChiNhanh getChiNhanh() {
		return chiNhanh;
	}

	public void setChiNhanh(ChiNhanh chiNhanh) {
		this.chiNhanh = chiNhanh;
	}

	@Column(name = "name", unique = true)
	@Length(max = 250)
	@NotBlank
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
